﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Domain
{
    public class Nominal
    {
        private string _value;

        public Nominal(string value, string label)
        {
            this.Value = value;
            this.Label = label;
        }

        public string Value
        {
            get { return this._value; }
            set
            {
                if (String.IsNullOrEmpty(value))
                    throw new ArgumentException("Value cannot be null or empty");

                this._value = value;
            }
        }

        public string Label { get; private set; }

        public override bool Equals(object obj)
        {
            Nominal comp = obj as Nominal;

            return  comp != null &&
                    this.Value.Equals(comp.Value, StringComparison.InvariantCultureIgnoreCase) &&
                    String.Equals(this.Label, comp.Label, StringComparison.InvariantCultureIgnoreCase);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return this.Value.GetHashCode() * (this.Label == null ? 1 : this.Label.GetHashCode());
            }
        }

        public override string ToString()
        {
            //return this.Label ?? this.Value;
            return this.Value;
        }
    }
}
